package com.supinfo.suptracking.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;

/**
 *
 * @author Fabien, Jérémy, Ludovic, Brice
 */

@Entity
public class Car implements Serializable {
    
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    
    @ManyToOne
    @JoinColumn(name = "FK_USER")
    private User user;
    
    private String name;
    private String brand;
    
    @Column(name = "INITIAL_ENTRY_INTO_SERVICE")
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date initialEntryIntoService;
    
    @Column(name = "ACTUAL_LATITUDE")
    private String actualLatitude;
    
    @Column(name = "ACTUAL_LONGITUDE")
    private String actualLongitude;
    
    @OneToMany(mappedBy = "car")
    @JoinColumn(name = "FK_POSITION_LIST")
    private List<Gpspositionhistory> positionList;
    
    @OneToMany(mappedBy = "car")
    @JoinColumn(name = "FK_ZONES_LIST")
    private List<Zone> zonesList;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public Date getInitialEntryIntoService() {
        return initialEntryIntoService;
    }

    public void setInitialEntryIntoService(Date initialEntryIntoService) {
        this.initialEntryIntoService = initialEntryIntoService;
    }

    public String getActualLatitude() {
        return actualLatitude;
    }

    public void setActualLatitude(String actualLatitude) {
        this.actualLatitude = actualLatitude;
    }

    public String getActualLongitude() {
        return actualLongitude;
    }

    public void setActualLongitude(String actualLongitude) {
        this.actualLongitude = actualLongitude;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Car)) {
            return false;
        }
        Car other = (Car) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.suptracking.entity.Car[ id=" + id + " ]";
    }
}
